<template>
  <el-card>
    <div slot="header" class="clearfix">
      <span>最新疫情肺炎新闻</span>
    </div>
    <div class="text item news">
      <el-table
      :data="newsList">
      <el-table-column
        prop="updateTime"
        label="日期"
        width="250px">
      </el-table-column>
      <el-table-column
        prop="title"
        label="新闻标题"
        >
      </el-table-column>
      <el-table-column
        prop="sourceUrl"
        label="链接地址"
        >
      </el-table-column>
    </el-table>
    </div>
  </el-card>
</template>

<script>
export default {
  data() {
    return {
      newsList: [],
      activeNames: []
    }
  },
  created() {
    this.getNews()
  },
  mounted() {
    this.newsList = JSON.parse(localStorage.getItem('newsList'))
  },
  methods: {
    // 获取最新疫情新闻
    async getNews() {
      await this.$axios.get('https://route.showapi.com/2217-4', {
        params: {
          showapi_appid: 951975.0,
          showapi_timestamp: '20220331090058',
          showapi_sign: 'b39a64fbc5e54221938719f2becc2737'
        }
      })
      .then((res) => {
        let newsList = res.data.showapi_res_body.newsList
        localStorage.setItem('newsList', JSON.stringify(newsList))
      }).catch((err) => {
        console.log(err);
      })
    },
    // 
    handleChange(val) {
      console.log(val);
    },
  }
}
</script>

<style lang="scss" scoped>
.news {
  width: 100%;
  ::v-deep .el-table__body {
    width: 100%;
  }
}
</style>